package Comp355Final.main;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;



public class BookShelfchClickListener implements OnClickListener{
	private GUIBookShelfChSelect parent;
	private TextView txt_view;
	private FileIO fileio;
	private String dest;
	private Config myconfig;
	private String chapter_name;
	private String book_folder;

	public BookShelfchClickListener( GUIBookShelfChSelect parent, TextView txt_view, String dest, Config myconfig,String book_name,String book_folder)
	{
		this.parent=parent;
		this.txt_view=txt_view;
		this.dest=dest;
		this.myconfig=myconfig;
		this.chapter_name=book_name;
		this.book_folder=book_folder;
	}
	public void onClick(View v) {
		//l_layout.setBackgroundColor(Color.GREEN);
		//readText readtxt = new readText(parent,fileio,dest,charset);
		go_toViewer(parent,dest,chapter_name,book_folder);
		
	}
	public static void go_toViewer(GUIBookShelfChSelect parent,String dest,String chapter_name,String book_folder)
	{
		
		//Utility.quick_dialog("Determining", parent);
		if(dest.toLowerCase().endsWith("jpg")||dest.toLowerCase().endsWith("gif")||dest.toLowerCase().endsWith("png"))
		{
			Intent int_ent = new Intent(parent, GUIReadImg.class);
			//Intent int_ent = new Intent(parent, LargeImageScroller.class);
			int_ent.putExtra("dest", dest);
			float tmp_zoom_scl = (float)1.000;
			int_ent.putExtra("zoom", tmp_zoom_scl);
			int_ent.putExtra("book_name", chapter_name);
			int_ent.putExtra("charset", parent.get_currCharset());
			int_ent.putExtra("book_folder", book_folder);
			//book_folder
			parent.startActivity(int_ent);
			//parent.startActivityForResult(int_ent, 1);
		}
		else if(dest.toLowerCase().endsWith("txt"))
		{
			Intent int_ent = new Intent(parent, GUIReadText.class);
			int_ent.putExtra("dest", dest);
			int_ent.putExtra("charset", parent.get_currCharset());
			int_ent.putExtra("book_name", chapter_name);
			int_ent.putExtra("book_folder", book_folder);
			parent.startActivity(int_ent);
		}

	}
}


